package ln.fxspringarchetype.controller.course;

import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.util.converter.NumberStringConverter;
import ln.fxspringarchetype.controller.BaseFxController;
import ln.fxspringarchetype.vo.CourseVO;

public class EditCourseController extends BaseFxController {
    private final CourseVO courseVO = new CourseVO();
    @FXML
    private Label idLabel;
    @FXML
    private TextField creditField;
    @FXML
    private TextField descriptionField;
    @FXML
    private TextField nameField;

    public CourseVO getCourseVO() {
        return courseVO;
    }

    @Override
    public void setCellValueFactories() {

    }

    @Override
    public void setCellFactories() {

    }

    @Override
    public void createBindings() {
        idLabel.textProperty().bind(
                Bindings.createStringBinding(
                        () -> Integer.toString(courseVO.getId()), courseVO.idProperty()));
        nameField.textProperty().bindBidirectional(courseVO.nameProperty());
        descriptionField.textProperty().bindBidirectional(courseVO.descriptionProperty());
        Bindings.bindBidirectional(
                creditField.textProperty(),
                courseVO.creditProperty(),
                new NumberStringConverter());
    }

    @Override
    public void initLayout() {

    }

    @Override
    public void loadData() {

    }
}
